Skip to content

Fix/issues#18447,And a module for setting Beta function Settings has been added, allowing users to control whether to enable certain functions #20352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tinet-dongfb
Copy link
Contributor

@tinet-dongfb tinet-dongfb commented May 28, 2025

Summary

Fixes #18447

The previously submitted PR caused some issues, so this time it's not just about fixing the problems that emerged;
Fixes #19784
Fixes #19782
Fixes #19771
Fixes #19768

PR: #19732, PR: #19744 The modified code has been modified synchronously

In addition, a configuration page for the Beta function has been added. It is hoped that the creator of the workspace can decide for themselves whether to enable this function

But I 'm not a pure backend developer, although beta_config was added to the tenants table, do I know how to submit changes to the table structure to you? Hope you can handle the structural change of this table. The table structure statement is

alter table tenants
	add beta_config text;

Some front-end unit tests will be added for this function in the future, but this will take a little time

Screenshots

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • [] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. 💪 enhancement New feature or request 📚 documentation Improvements or additions to documentation labels May 28, 2025
@crazywoola crazywoola requested review from laipz8200 and Copilot May 28, 2025 08:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes several issues related to variable validations across workflow node types and adds a new beta configuration module to allow workspace creators to control experimental features. Key changes include:

  • Adding and synchronizing checkVarValid functions to validate variables in various workflow nodes.
  • Integrating beta configuration both in the backend (table modifications, API endpoints) and frontend (account settings, beta page).
  • Minor refactoring of import statements and adjustments to dependency updates in checklist hooks.

Reviewed Changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.

File Description
web/app/components/workflow/nodes/* Added checkVarValid functions for variable validation across multiple node types.
web/app/components/workflow/header/account-setting/* Introduced beta configuration UI support and adjusted component imports.
api/* Updated database schema and API endpoints to support beta_config.
Comments suppressed due to low confidence (1)

web/app/components/header/account-setting/index.tsx:36

  • Consider renaming the imported component from 'BatePage' to 'BetaPage' to maintain consistency with conventional naming.
import BatePage from './beta-page'

checkVarValid(payload: AssignerNodeType, varMap: Record<string, Var>, t: any) {
const errorMessageArr: string[] = []
const items = payload.items ?? []
const variables_warnings = getNotExistVariablesByArray(items.map(item => item.variable_selector ?? []) ?? [], varMap)
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that 'item.variable_selector' consistently returns a string value; using an empty array as a fallback may lead to type inconsistencies in variable validation.

Copilot uses AI. Check for mistakes.

if (variables_warnings.length)
errorMessageArr.push(`${t('workflow.nodes.assigner.assignedVariable')} ${t('workflow.common.referenceVar')}${variables_warnings.join('、')}${t('workflow.common.noExist')}`)

const value_warnings = getNotExistVariablesByArray(items.map(item => item.value ?? []) ?? [], varMap)
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that 'item.value' consistently returns a string value; using an empty array as a fallback may lead to unexpected behavior during variable validation.

Copilot uses AI. Check for mistakes.

@@ -199,6 +199,7 @@ class Tenant(Base):
plan = db.Column(db.String(255), nullable=False, server_default=db.text("'basic'::character varying"))
status = db.Column(db.String(255), nullable=False, server_default=db.text("'normal'::character varying"))
custom_config = db.Column(db.Text)
beta_config = db.Column(db.Text)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the issue you mentioned, but I'm having trouble understanding why we need this field. It appears to store an unvalidated JSON structure directly in the database. Could you please provide a detailed explanation of its purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to set a switch or configuration for the Beta function of the workspace, so I need this field. But what you said is an unverified JSON structure, which does seem to be an unsafe design indeed

@tinet-dongfb
Copy link
Contributor Author

There are still some issues in this PR that failed the test

@laipz8200
Copy link
Member

@tinet-dongfb I tested this feature, and it effectively detects non-existent variables. I believe we can implement it as a permanent feature without requiring a beta toggle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Improvements or additions to documentation 💪 enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
2 participants